<?php
$uname=isset($_GET['uname'])?$_GET['uname']:'';
$sex=isset($_GET['sex'])?$_GET['sex']:'';
$starttime=isset($_GET['starttime'])?$_GET['starttime']:'';
$endtime=isset($_GET['endtime'])?$_GET['endtime']:'';
$order=isset($_GET['order'])?$_GET['order']:'';
?>
<div class="btn-group">
    <a class='btn btn-primary' href="<?php echo site_url('user/create')?>"> 添加会员 </a>
</div>
<div class="clearfix"><p></p></div>

<form class="form-inline" action="<?php echo site_url($this->class.'/search'); ?>" method="GET" name="form1">
    <input name="uname" type="text" title="搜索页面" value="<?php echo $uname; ?>" placeholder="请输入手机号码/用户名">
    <select name="sex">
        <option value="">请选择性别</option>
        <option value="1" <?php if($sex==1):?>selected="selected"<?php endif;?>>男</option>
        <option value="2" <?php if($sex==2):?>selected="selected"<?php endif;?>>女</option>
    </select>
    <p></p>
    <div class="control-group">
        <div class="controls">
            <label for="title" class="control-label">注册时间:</label>
            <div class="input-append date timepicker" id="datetimepicker1">
                <input type="text" placeholder="起始时间"  value="<?php if(!empty($_GET['starttime'])){echo $_GET['starttime'];} ?>" id="ts" name="starttime" data-date-format="yyyy-mm-dd hh:ii:ss">
                <span class="add-on"><i class="icon-th"></i></span>
            </div>

            <div class="input-append date timepicker" id="datetimepicker2">
                <input type="text" placeholder="结束时间" value="<?php if(!empty($_GET['endtime'])){echo $_GET['endtime'];} ?>" id="te" name="endtime" data-date-format="yyyy-mm-dd hh:ii:ss">
                <span class="add-on"><i class="icon-th"></i></span>
            </div>
        </div>
    </div>
    <p></p>
    <label for="title" class="control-label">排序条件:</label>
    <select name="order">
        <option value="1" <?php if($order==1):?>selected="selected"<?php endif;?>>注册时间 ↓</option>
        <option value="2" <?php if($order==2):?>selected="selected"<?php endif;?>>注册时间 ↑</option>
    </select>
    <p></p>
    <input class="btn" type="submit" value="检索">

</form>

<div class="clearfix"><p></p></div>

<?php include_once 'inc_ui_limit.php'; ?>
<p></p>
<div class="clearfix"></div>
<p></p>
<div class="boxed">
    <div class="boxed-inner seamless">
        <table class="table table-striped table-hover select-list">
            <thead>
            <tr>
                <th>用户名</th>
                <th>手机</th>
                <th>Email</th>
                <th>企业信息</th>
                <th>子账户列表</th>
                <th>子账户分类列表</th>
                <th>时间</th>
            </tr>
            </thead>
            <tbody class="sort-list">
            <?php foreach ($list as $v):?>
                <tr data-id="<?php echo $v['id'] ?>" >
                    <td> <?php echo $v['uname'] ?> </td>
                    <td> <?php echo $v['phone'] ?> </td>
                    <td> <?php echo $v['email'] ?> </td>
                    <td> <a href="javascript:;" class="company" data-company="<?php echo $v['is_company'] ?>" data-id="<?php echo $v['id'] ?>">企业信息</a> </td>
                    <td> <a href="<?php echo site_url('user/subsidiary/'.$v['id']); ?>">子账户列表</a> </td>
                    <td> <a href="<?php echo site_url('user/subsidiaryAction/'.$v['id']); ?>">子账户分类列表</a> </td>
                    <td> <?php echo  date("Y/m/d H:i:s",$v['timeline']); ?> </td>
                    <td style="text-align:right;">
                        <div class="btn-group">
                            <a class='btn btn-small' href=" <?php echo site_url( $this->router->class.'/edit/'.$v['id']) ?> " title="<?php echo lang('edit') ?>"> <i class="fa fa-pencil"></i></a>
                        </div>
                    </td>
                </tr>
            <?php endforeach;?>
            </tbody>
        </table>
    </div>
</div>

<!--<div class="btn-group">-->
<!--    <a id='select-all' class='btn' href="#"> <i class=""></i> --><?php //echo lang('select_all') ?><!-- </a>-->
<!--    <a id='unselect-all' class='btn hide' href="#"> <i class=""></i> --><?php //echo lang('unselect') ?><!-- </a>-->
<!--    <a id="btn-del" class='btn btn-danger' href="#"> <i class="fa fa-times"></i> --><?php //echo lang('del') ?><!-- </a>-->
<!--</div>-->

<?php echo $pages; ?>

<script>
    require(['adminer/js/ui', 'web/js/layer/layer','bootstrap-datetimepicker.zh'],function(ui,layer){
        layer.config({
            path: STATIC_URL + 'web/js/layer/' //layer.js所在的目录，可以是绝对目录，也可以是相对目录
        });
        $('.timepicker').datetimepicker({'language':'zh-CN','format':'yyyy/mm/dd hh:ii:ss','todayHighlight':true});
        acount = {
            url_del: "<?php echo site_url('user/delete'); ?>"
            //,url_sortid: "<?php echo site_url('user/sortid'); ?>"
            ,url_audit: "<?php echo site_url('user/audit'); ?>"
        };

        ui.btn_delete(acount.url_del);		// 删除
        //ui.sortable(acount.url_sortid);	// 排序
        ui.btn_audit(acount.url_audit);// 审核
        $('.company').click(function(){
            var company=$(this).attr('data-company');
            var id=$(this).attr('data-id');
            if(company==1){
                window.location.href="<?php echo site_url('user/user_company'); ?>"+"/"+id;
            }else{
                layer.msg('企业信息未填写');
            }
        });
    });
</script>
